﻿<html>

<head>
<title>Plan zajęć</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> 
<!--<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" />-->

<style type="text/css">
#divPlan {
	width: 1000px;

}
td,tr,th {
	border: solid 1px #000000 ;
	text-align: center;
}
th {
	width: 200px;
}
.hour {
	width:30px;
	text-align: right;
	font-weight:bold;
}
td.nonempty {
	background-color: #EAEAEA;
}

#planTable {
	border: solid 3px #000000;
	width: 1000px;
}
#student {
	font-weight:bold;
}
</style>
</head>
<body>

<?php
include 'dbConnection.php';
$indeks = 111111;
$pesel = 11111111111;

$planItem = array();

$result = mssql_query("EXECUTE getPlan $indeks, $pesel");

while($row = mssql_fetch_array($result)) {
		$przedmiot = iconv("CP1250","utf-8",$row['przedmiot']);
		$gid = $row['id'];
		$skrot = $row['skrot'];
		$nazwa = $row['nazwa'];
		$godz = $row['godz'];
		$dzien = $row['dzien'];
		$sala = $row['sala'];
		$student = iconv("CP1250","utf-8",$row['student']);
		$prowadzacy = iconv("CP1250","utf-8",$row['prowadzacy']);
		
		$planItem[$godz][$dzien] = $przedmiot.'<br />'.$skrot.' '.$nazwa.'<br />'.$prowadzacy.'<br />Sala: '.$sala;
		//echo '<span class="lab" id="lab_'.$row['id'].'" onclick="selectCwiczenia('.$row['id'].')">'.$line.'</span>';
	}

echo '<div id="student">'.$student.'</div>';
echo '<div id="indeks">Nr indeksu: '.$indeks.'</div>';	

?>

<h1>Twój plan zajęć</h1>
<div id="divPlan">
				<table id="planTable">                            
				    <tbody>
					<!--plan of lessons-->
					<tr>
					<th style="width:45px;"></th>
					    <th>Poniedziałek</th>
					    <th>Wtorek</th>
					    <th>Środa</th>
					    <th>Czwartek</th>
					    <th>Piątek</th>
					</tr>
<?php


$hours1 = array(1 => '08:15','10:00','11:45','13:45','15:30','17:15');
$hours2 = array(1 => '09:45','11:30','13:15','15:15','17:00','18:45');
for ($i = 1; $i<7; $i++) {
	echo '<tr>';
	echo '	<td class="hour">'.$hours1[$i].'<br/>'.$hours2[$i].'</td>';
	for ($j =1; $j<6; $j++) {
		if(isset($planItem[$hours1[$i]][$j])) {
				echo '<td class="nonempty" id="td'.$j.$i.'">'.$planItem[$hours1[$i]][$j].'</td>';
			
			
		}
		else {
			echo '<td id="td'.$j.$i.'"><p> </p></td>';
		}
	}
	echo '</tr>';
}
mssql_free_result($result);
mssql_close($con);
?>


				    </tbody>
				</table>
			</div>






</body>
</html>


